<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>后台主界面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/admin.css' type="text/css" />
<script src="<?php echo $static_url; ?>common/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="<?php echo $static_url; ?>common/js/common.js" type="text/javascript"></script>
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/user_list.css' type="text/css" />
</head>
<body class="body_background">
	<div>
		<?php echo $header_nav; ?>
		<div style="margin-top:15px;">
		<div class="crumbs">
			<span class="catalogue">权限管理</span>
			<a href="/www/admin/role/position_lists.php">职务管理</a> | <a href="/www/admin/role/user_lists.php">人员管理</a>
		</div>
		<div class="edit_user_container">
		<table class="record_tips"><tr><td class="colorstyle">人员管理权限编辑</td></tr></table>
		<form id="edit_form" method="post" action="/www/admin/role/do/do_edit_user.php">
			<p class="p_user_content"><label class="eidt_user_label">用户名：</label><?php echo $users_rs['username']; ?></p>
			<p class="p_user_content"><label class="eidt_user_label">职务：</label><?php echo $users_rs['name']; ?></p>
			<p class="p_user_content"><label class="eidt_user_label">状态：</label><label><input type="checkbox" value="2" style="vertical-align:middle;" <?php echo ($users_rs['locked']!=1)?'checked="checked"':''; ?> name="locked"/>锁定</label></p>
			<?php foreach($roles_type_arr as $top_type): ?>
				<div class="power_container">
					<div class="allcheckedDiv">
						<label>
							<input type="checkbox" id="type_<?php echo $top_type['id']; ?>" onclick="select_top(<?php echo $top_type['id']; ?>)"/>
							<?php echo $top_type['name']; ?>
						</label>
					</div>
					<ul class="powerUl clearfix">
						<?php foreach($top_type['child'] as $child_type): ?>
							<li>
								<label>
									<input type="checkbox" value="<?php echo $child_type['id']; ?>" name="modelid[]" id="type_<?php echo $top_type['id']; ?>_<?php echo $child_type['id']; ?>" onclick="select_child(<?php echo $top_type['id']; ?>)" <?php echo (in_array($child_type['id'],$operation_arr))?'checked="checked"':''; ?>/>
									<?php echo $child_type['name']; ?>
								</label>
							</li>
						<?php endforeach; ?>
						<script>$(function(){select_child(<?php echo $top_type['id']; ?>)});</script>
					</ul>
				</div>
			<?php endforeach; ?>
			<input type="hidden" name="uid" value="<?php echo $users_rs['uid']; ?>" />
			<input type="submit" style="margin:10px 20px;" class="submit_style" value="提交">
		</form>
		</div>
	</div>
	</div>
<script>
//大栏目的全选/取消
function select_top(id){
	if( $('#type_'+id).is(':checked') ){
		$("[id^=type_"+id+"_]").prop("checked", true);
	}else{
		$("[id^=type_"+id+"_]").prop("checked", false);
	}
}

//绑定小栏目的点击事件
function select_child(id){
	var checked_all = true;
	$("[id^=type_"+id+"_]").each(function(){
		if( !$(this).is(':checked') ){
			checked_all = false;
		}
	});
	if( checked_all ){
		$('#type_'+id).prop("checked", true);
	}else{
		$('#type_'+id).prop("checked", false);
	}
}
</script>
</body>
</html>